<%--
  Created by IntelliJ IDEA.
  User: 0927
  Date: 2020/10/13
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏车辆</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/sellCar.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/footer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/perCenter.css">
    <style>
        .img-p{
            width: 60px;
            height: 60px;
            margin: 30px auto 10px;
            background: url("${pageContext.request.contextPath}/images/xrb.png") no-repeat;
        }
    </style>
</head>
<body class="body">
<!--nav开始-->
<div id="nav_my">

</div>
<!--nav结束-->
<!--nav beigin-->
<%--<div class="container-fluid">--%>

<div class="container">
    <div class="jumbotron">
        <div class="row">
            <form class="form-horizontal" role="form">
                <div class="form-group col-lg-3">
                    <label for="uname" class="col-md-3 control-label">姓名</label>
                    <div class="col-md-9">
                        <input type="text" class="form-control" name="uname" id="uname" value="${detail.uname}">
                    </div>
                </div>
                <div class="form-group col-lg-3">
                    <label for="upwd" class="col-md-3 control-label">密码</label>
                    <div class="col-md-9">
<%--                        <input type="text" class="form-control" name="upwd" id="upwd" value="${detail.upwd}">--%>
                            <input type="text" class="form-control" name="upwd" id="upwd" >
                    </div>
                </div>
                <div class="form-group col-lg-3">
                    <label for="uphoto" class="col-md-3 control-label">头像</label>
                    <div class="col-md-9">
                        <input type="text" class="form-control" name="uphoto" id="uphoto" value="${detail.uphoto}">
                    </div>
                </div>
                <div class="form-group col-lg-3">
                    <div class="col-md-offset-2 ">
                        <button type="button" class="btn btn-primary" onclick="update()">修改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2" id="myScrollspy">
            <ul class="nav nav-tabs nav-stacked" data-spy="affix" data-offset-top="125">
                <li>
                    <p class="img-p"></p>
                    <p class="user-info">个人中心
                        <span>手机号：${detail.uphone}</span>
                    </p>
                </li>
                <li id="aa"><a onclick='perStore()' href="javascript:void(0);">收藏车辆</a></li>
                <li id="bb" class="active"><a onclick='perHistory()' href="javascript:void(0);">浏览记录</a></li>
                <li id="cc"><a onclick='perReduce()' href="javascript:void(0);">降价提醒</a></li>
            </ul>
        </div>

        <%--        <div class="col-md-9 person">--%>
        <div class="col-md-10" id="outer">


        </div>
    </div>
    <br>
</div>

<%--</div>--%>
<!--footer-->
<div id="footer">

</div>
<!--footer-->
<!--question end-->
<script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<script type="text/javascript"></script>
<script>

    function update(){

        let upwd = $("#upwd").val();
        let uname = $("#uname").val();
        let uphoto = $("#uphoto").val();
        if(!(/^(\w){6,12}$/.test(upwd))){
            alert("密码不符合要求，请重新填写");
            return;
        }else if (!uname){
            alert("姓名不能为空")
            return;
        }
        let register_value = {"upwd":upwd,"uname":uname,"uphoto":uphoto};
        //发送key-value
        $.post('${pageContext.request.contextPath}/userDetail/update',register_value,function(data){
            if (data.code == 200){
                document.getElementById("uname").value=data.data.uname;
                document.getElementById("upwd").value=data.data.upwd;
                document.getElementById("uphoto").value=data.data.uphoto;
                alert("修改成功")
            }else {
                alert("网络异常")
            }
        });
    }
    function perStore() {
        $("#aa").attr("class","active");
        $("#bb").attr("class","bb");
        $("#cc").attr("class","cc");
        // $("#aa").addClass("active")
        // $("#aa").css('background-color','#0088cc');
        $("#outer").load("${pageContext.request.contextPath}/Personal/Store");
        // document.getElementById("#aa").className = "ww";

    }

    function perHistory() {
        $("#aa").attr("class","aa");
        $("#bb").attr("class","active");
        $("#cc").attr("class","cc");
        $("#outer").load("${pageContext.request.contextPath}/Personal/history");
    }

    function perReduce() {
        $("#aa").attr("class","aa");
        $("#bb").attr("class","bb");
        $("#cc").attr("class","active");
        $("#outer").load("${pageContext.request.contextPath}/Personal/reduce");
    }

    function del(obj,id){
        $.post('${pageContext.request.contextPath}/Personal/delHistory',{"id":id},function(data){
            if(data.code=="200"){
                let div = obj.parentElement.parentElement.parentElement.parentElement.parentElement;
                $(div).remove();
            }else {
                alert("删除失败")
            }
        })
    }
    $(function(){
        $("#nav_my").load("${pageContext.request.contextPath}/loadJsp/toNav");
        $("#outer").load("${pageContext.request.contextPath}/Personal/history");
        $("#footer").load("${pageContext.request.contextPath}/loadJsp/toFooter");
    })
</script>
</body>
</html>



